package com.mapproject.industrymap.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mapproject.industrymap.entity.EstateInfoEntity;
import org.beetl.ext.fn.ParseInt;
import org.springframework.stereotype.Component;
import springfox.documentation.spring.web.json.Json;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@Component
public class JDBCOperation{

    /**
     * @method getConn() 获取数据库的连接
     * @return Connection
     */
    public Connection getConn() {
        String driver = "org.postgresql.Driver";
        //String url = "jdbc:postgresql://218.93.116.192:5432/industrymap";
        String url = "jdbc:postgresql://localhost:5432/WJMap";
        String username = "postgres";
        //String password = "Wjgh@123";
        String password = "lvshuangxi";
        Connection conn = null;
        try {
            Class.forName(driver); // classLoader,加载对应驱动
            conn = (Connection) DriverManager.getConnection(url, username, password);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }


}
